package com.nanychuan.blogbase.controller;

import com.nanychuan.blogback.pojo.User;
import com.nanychuan.blogbase.utils.DateTimeUtil;
import com.nanychuan.blogbase.utils.UploadFileUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * @author 往
 * 上传文件
 */
@Controller
public class FileUploadController {
    //editorMd文件上传
    @RequestMapping("/blog/editorUpload")
    @ResponseBody
    public Map<String,Object> editorUploadFile(@RequestParam(value = "editormd-image-file",required = false)MultipartFile img, HttpSession session){
        Map<String, Object> map = UploadFileUtil.fileUpload(img, session);
        return map;
    }

    //Logo图片文件上传
    @RequestMapping("/blog/logoFileUpload")
    @ResponseBody
    public Map<String,Object> LogoUploadFile(MultipartFile img, HttpSession session){
        Map<String, Object> map = UploadFileUtil.fileUpload(img, session);
        return map;
    }
}
